package com.markhsiu.MiniMQ.core.constant;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 常量工具
 * Created by Mark Hsiu on 2017/2/8.
 */
public class ConstantUtil {


    /**
     * 当前系统的进程*2
     */
    private static int workerThreads = Runtime.getRuntime().availableProcessors() * 2;
    private static final ExecutorService pools = Executors.newFixedThreadPool(workerThreads);

    /**
     * 换行符
     */
    public  static final String LINE_SEQ = System.getProperty("line.separator");
    public  static String toLineFrame(String orgin){
        return orgin + LINE_SEQ;
    }

    public static int getWorkerThreads() {
        return workerThreads;
    }

    public static void setWorkerThreads(int workers) {
        workerThreads = workers;
    }
    
    public static void threadPools(Runnable command) {
    		pools.execute(command);
    }
}
